package com.clayecloud.module_house.entity;

import android.widget.ImageView;

import androidx.databinding.BaseObservable;
import androidx.databinding.Bindable;
import androidx.databinding.BindingAdapter;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;

public class House extends BaseObservable {

    /**
     * 房屋id
     */
    private int houseID;

    /**
     * 房屋所在城市
     */
    private String city;

    /**
     * 房屋所在小区
     */
    private String community;

    /**
     * 房号
     */
    private String room;

    /**
     * 房屋封面图
     */
    private String houseImage;

    /**
     * 房屋类型
     */
    private String houseType;

    public House(int houseID, String city, String community, String room, String houseImage, String houseType) {
        this.houseID = houseID;
        this.city = city;
        this.community = community;
        this.room = room;
        this.houseImage = houseImage;
        this.houseType = houseType;
    }

    @Bindable
    public int getHouseID() {
        return houseID;
    }

    public void setHouseID(int houseID) {
        this.houseID = houseID;

    }

    @Bindable
    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    @Bindable
    public String getCommunity() {
        return community;
    }

    public void setCommunity(String community) {
        this.community = community;
    }

    @Bindable
    public String getRoom() {
        return room;
    }

    public void setRoom(String room) {
        this.room = room;
    }

    public String getHouseImage() {
        return houseImage;
    }

    public void setHouseImage(String houseImage) {
        this.houseImage = houseImage;
    }

    @Bindable
    public String getHouseType() {
        return houseType;
    }

    public void setHouseType(String houseType) {
        this.houseType = houseType;
    }

    @BindingAdapter({"coverPhoto"})
    public static void getCoverPhoto(ImageView view, String cover_photo){
        RoundedCorners roundedCorners = new RoundedCorners(15);
        //通过RequestOptions扩展功能,override:采样率,因为ImageView就这么大,可以压缩图片,降低内存消耗
        // RequestOptions options = RequestOptions.bitmapTransform(roundedCorners).override(300, 300);
        RequestOptions options = RequestOptions.bitmapTransform(roundedCorners);
        Glide.with(view.getContext()).load(cover_photo).apply(options).into((ImageView) view);
    }

}
